pub use clap::Parser;
use clap::{Subcommand, command};

/// Welcome to use guide config parser
#[derive(Parser)]
#[command(version, author, about, long_about)]
pub struct Config {
    /// Specify your operator
    #[command(subcommand)]
    pub op: Operator,
}

#[derive(Subcommand)]
pub enum Operator {
    Transfer {
        /// - Gnt1.0Test <- 传入这个层级的路径
        ///     - xxx1.gnt
        ///     - xxx2.gnt
        ///     - ...
        /// - Gnt1.0Train
        ///     - xxx1.gnt
        ///     - xxx2.gnt
        ///     - ...
        #[arg(long, short)]
        raw_dir: String,
        /// - Images <- 存放图片的层级
        ///     - xxx1
        ///         - xxx1_1.png
        ///         - xxx1_2.png
        ///         - ...
        ///     - xxx2
        ///         -...
        ///     -...
        #[arg(long, short)]
        images_dir: String,
    },
    Unzip {
        /// + hwdb   <- 传入这个层级的路径
        ///     + Gnt1.0Test.zip
        ///     + Gnt1.0TrainPart1.zip
        ///     + ...
        #[arg(long, short)]
        zip_dir: String,
        /// - hwdb-images    <- 输出的图片保存路径
        ///     - Gnt1.0Test
        ///     - Gnt1.0TrainPart1
        #[arg(long, short)]
        save_dir: String,
        #[arg(long, default_value_t = true)]
        smart_check: bool,
        #[arg(long = "trn")]
        trn_list: Vec<String>,
        #[arg(long = "tst")]
        tst_list: Vec<String>,
        #[arg(long = "vld")]
        vld_list: Vec<String>,
        #[arg(long, default_value_t = String::from("train"))]
        trn_tag: String,
        #[arg(long, default_value_t = String::from("test"))]
        tst_tag: String,
        #[arg(long, default_value_t = String::from("valid"))]
        vld_tag: String,
        /// hdf5文件名，指定了就保存到hdf5中,
        /// 不指定就保存到文件夹中
        #[arg(long, default_value_t = String::from("hwdb.h5"))]
        hdf5: String,
        /// 指定是否启用hdf5
        #[arg(long, short, default_value_t = true)]
        use_hdf5: bool,
    },
    Preprocess {
        #[arg(long, short)]
        images_dir: String,
        #[arg(long, default_value_t = String::from("classes.txt"))]
        classes_filename: String,
        #[arg(long, default_value_t = String::from("labels.txt"))]
        label_filename: String,
        #[arg(long, default_value_t = String::from("train"))]
        trn_tag: String,
        #[arg(long, default_value_t = String::from("test"))]
        tst_tag: String,
        #[arg(long, default_value_t = String::from("valid"))]
        vld_tag: String,
    },
    Train {
        #[arg(long, short)]
        images_dir: String,
        #[arg(long, short)]
        log_dir: String,
        #[arg(long, default_value_t = String::from("classes.txt"))]
        classes_filename: String,
        #[arg(long, default_value_t = String::from("labels.txt"))]
        label_filename: String,
        #[arg(long, default_value_t = 10)]
        num_epoches: usize,
        #[arg(long, default_value_t = 32)]
        batch_size: usize,
        #[arg(long, default_value_t = 4)]
        num_workers: usize,
        #[arg(long, default_value_t = 1007)]
        seed: u64,
        #[arg(long, default_value_t = 1e-4)]
        lr: f64,
        #[arg(long, default_value_t = 184)]
        image_size: usize,
        #[arg(long, default_value_t = String::from("train"))]
        trn_tag: String,
        #[arg(long, default_value_t = String::from("test"))]
        tst_tag: String,
        /// hdf5文件名，指定了就保存到hdf5中,
        /// 不指定就保存到文件夹中
        #[arg(long, default_value_t = String::from("hwdb.h5"))]
        hdf5: String,
        /// 指定是否启用hdf5
        #[arg(long, short, default_value_t = true)]
        use_hdf5: bool,
    },
    Infer {
        #[arg(long, short)]
        log_dir: String,
        #[arg(long = "h5")]
        h5_filepath: String,
        #[arg(long, short)]
        images_path: Vec<String>,
        #[arg(long = "inter")]
        intermediate_image_save_path: Option<String>,
    },
}
